﻿using BattleFury.Server.Events;
using System;
using System.Text;

namespace BattleFury.Server.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var server = new FuryServer();
            server.OnConsoleMessage += ServerConsoleMessageReceived;

            server.Start();

            System.Console.ReadKey();

            server.Shutdown();
        }

        private static StringBuilder sb = new StringBuilder();
        private static DateTime time = DateTime.Now;
        private static void ServerConsoleMessageReceived(object sender, ConsoleMessageEventArgs args)
        {
            sb.AppendLine(args.Message);
            if (DateTime.Now.Subtract(time).Seconds > 1)
            {
                System.Console.WriteLine(sb.ToString());
                sb.Clear();
                time = DateTime.Now;
            }
        }
    }
}